<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

	<head>
		<base href="<%=request.getContextPath()%>/">
		<title></title>
		<link rel="stylesheet" type="text/css" href="Styles/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="Styles/admin-all.css" />
		<script type="text/javascript" src="Scripts/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="Scripts/jquery-ui-1.8.22.custom.min.js"></script>
		<link rel="stylesheet" type="text/css" href="Styles/ui-lightness/jquery-ui-1.8.22.custom.css" />
		<script type="text/javascript" src="Scripts/tip.js"></script>
		<script type="text/javascript">
			$(function() {
				$('#list').hide();
				$(".datepicker").datepicker();
				$('#startime').tooltip({
					title: '起始日期'
				});
				$('#endtime').tooltip({
					title: '结束日期'
				});
			})
		</script>
	</head>

	<body>
		<div></div>
		<div class="alert alert-info">当前位置<b class="tip"></b>绩效管理<b class="tip"></b>考勤查询</div>
		<table class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<td colspan="4" class="auto-style2">&nbsp;请填写查询条件 </td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<shiro:hasRole name="admin">
						<td style="text-align:center;">工号</td>
						<td class="detail">
							<input id="formid" />
						</td>
					</shiro:hasRole>
					<td style="text-align:center;">查询日期 </td>
					<td>
						<div class="input-append">
							<input class="span2 datepicker" size="16" type="text" id="startime" /><span class="add-on"><i class="icon-calendar"></i></span>至<input id="endtime" class="span2 datepicker" size="16" type="text" /><span class="add-on"><i class="icon-calendar"></i></span>
						</div>
					</td>
				</tr>
				<tr>
					<td colspan="4" align="right">
						<input class="btn btn-inverse" id="find" type="button" value="查询" />
					</td>
				</tr>
			</tbody>
		</table>

		<table class="table table-striped table-bordered table-condensed" id="list">
			<thead>
				<tr class="tr_detail">
					<td style="width:30px">工号 </td>
					<td>姓名</td>
					<td>上班卡</td>
					<td>下班卡</td>
					<td>日期</td>
				</tr>
			</thead>
			<tbody id="test">

			</tbody>
		</table>

	</body>

</html>
<script>
	$(function() {

		$('#find').click(function() {
			var name = '${emp.empName }';
			var aa = '${number }';
			var id = $("#formid").val();
			if(name == 'admin') {
				if(id == '') {

					$.post("kaoqin/list1", {
						startime: $('#startime').val(),
						endtime: $('#endtime').val()
					}, function(data) {

						//      		 alert(data)
						$("#test").html("");
						 
						var html_NewsLeft = "";

						        
						for(var i = 0; i < data.length; i++) {            
							var number = data[i].number;            
							var startime = data[i].startime;            
							var endtime = data[i].endtime;            
							var username = data[i].username; 
							var atdDate = data[i].atdDate.substring(0,10);

							html_NewsLeft += '<tr>' + '<td>' + number + '</td>' +
								'<td>' + username + '</td>' +
								'<td>' + startime + '</td>' +
								'<td>' + endtime + '</td>' +
								'<td>' + atdDate + '</td>' + '</tr>';
						}
						$("#test").html(html_NewsLeft);
						$('#list').show();
					})

				} else {
					$.post("kaoqin/list2", {
						empNum: id,
						startime: $('#startime').val(),
						endtime: $('#endtime').val()
					}, function(data) {
						$("#test").html("");
						 
						var html_NewsLeft = "";

						        
						for(var i = 0; i < data.length; i++) {            
							var number = data[i].number;            
							var startime = data[i].startime;            
							var endtime = data[i].endtime;            
							var username = data[i].username; 
							var atdDate = data[i].atdDate.substring(0,10);

							html_NewsLeft += '<tr>' + '<td>' + number + '</td>' +
								'<td>' + username + '</td>' +
								'<td>' + startime + '</td>' +
								'<td>' + endtime + '</td>' +
								'<td>' + atdDate + '</td>' + '</tr>';
						}
						$("#test").html(html_NewsLeft);
						$('#list').show();
					})
				}
			} else {
				$.post("kaoqin/list2", {
					empNum: aa,
					startime: $('#startime').val(),
					endtime: $('#endtime').val()
				}, function(data) {
					$("#test").html("");
					 
					var html_NewsLeft = "";

					        
					for(var i = 0; i < data.length; i++) {            
						var number = data[i].number;            
						var startime = data[i].startime;            
						var endtime = data[i].endtime;            
						var username = data[i].username; 
						var atdDate = data[i].atdDate.substring(0,10);

						html_NewsLeft += '<tr>' + '<td>' + number + '</td>' +
							'<td>' + username + '</td>' +
							'<td>' + startime + '</td>' +
							'<td>' + endtime + '</td>' +
							'<td>' + atdDate + '</td>' + '</tr>';
					}
					$("#test").html(html_NewsLeft);
					$('#list').show();
				})
			}

		})
	})
</script>